It's easier to see. Also drop old dead ot_main() function.
#include <errno.h>
#include <string.h>
+#include <unistd.h>
#include <locale.h>
#include "ot-main.h"
if (error != NULL)
{
- g_message ("%s", error->message);
+ int is_tty = isatty (1);
+ const char *prefix = "";
+ const char *suffix = "";
+ if (is_tty)
+ {
+ prefix = "\x1b[31m\x1b[1m"; /* red, bold */
+ suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */
+ }
+ g_printerr ("%serror: %s%s\n", prefix, suffix, error->message);
g_error_free (error);
}
}
return 0;
}
-
-int
-ostree_main (int argc,
- char **argv,
- OstreeCommand *commands)
-{
- GError *error = NULL;
- int ret;
-
- ret = ostree_run (argc, argv, commands, &error);
-
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
- ostree_usage (argv, commands, TRUE);
-
- if (error)
- {
- g_message ("%s", error->message);
- g_error_free (error);
- }
-
- return ret;
-}
int flags; /* OstreeBuiltinFlags */
} OstreeCommand;
-int ostree_main (int argc, char **argv, OstreeCommand *commands);
-
int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
int ostree_usage (char **argv, OstreeCommand *commands, gboolean is_error);